import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}

export const router = new VueRouter({
    routes: [
        {
            path: '/',
            redirect: '/a-home'
        },
        {
            path: '/a-home',
            component: () => import('../view/a-home')
        },
        {
            path: '/component',
            component: () => import('../view/component')
        },
        {
            path: '/introduce',
            component: () => import('../view/introduce')
        },
        {
            path: '/introduce/custom',
            component: () => import('../view/introduce/custom.vue')
        },
        {
            path: '/map',
            component: () => import('../view/map')
        },
        {
            path: '/cm-directives',
            component: () => import('../view/cm-directives')
        },
        {
            path: '/cm-directives/custom-drag',
            component: () => import('../view/cm-directives/custom-drag')
        },
        {
            path: '/big-screen',
            component: () => import('../view/big-screen')
        },
        {
            path: '/async-route',
            component: () => import('../view/async-route')
        },
        {
            path: '/global-component',
            component: () => import('../view/global-component')
        },
        {
            path: '/svg-icon',
            component: () => import('../view/svg-icon/detail.vue')
        },
        {
            path: '/img-mouse',
            component: () => import('../view/img-mouse')
        },
        {
            path: '/screen-flexible',
            component: () => import('../view/screen-flexible')
        },
        {
            path: '/screen-flexible/lib-flexible',
            component: () => import('../view/screen-flexible/lib-flexible')
        },
        {
            path: '/screen-flexible/rescale',
            component: () => import('../view/screen-flexible/rescale')
        },
        {
            path: '/ping',
            component: () => import('../view/ping')
        },
        {
            path: '/canvas',
            component: () => import('../view/canvas')
        },
        {
            path: '/canvas/dom-to-img',
            component: () => import('../view/canvas/dom-to-img')
        },
        {
            path: '/calendar',
            component: () => import('../view/calendar')
        },
        {
            path: '/video-timeline',
            component: () => import('../view/video-timeline')
        },
        {
            path: '*',
            component: () => import('../view/404')
        }
    ]
})